<!DOCTYPE HTML>
<title>Test that the media element is in correct state after load fails.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<video></video>
<script>
async_test(function(t) {
    var video = document.querySelector("video");
    assert_equals(video.error, null);

    video.oncanplaythrough = t.unreached_func();

    video.onerror = t.step_func_done(function () {
        assert_not_equals(video.error, null);
        assert_equals(video.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);

        // Actual message can vary greatly, so we only verify the attribute's type.
        assert_equals(typeof video.error.message, 'string', 'MediaError.message type');

        assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE);

        assert_true(isNaN(video.duration));
        assert_equals(video.currentTime, 0);
        assert_equals(video.buffered.length, 0);
        assert_equals(video.seekable.length, 0);
        assert_equals(video.buffered.length, 0);
    });

    video.src = "content/does-not-exist.mpeg";
});
</script>
